package com.abou.mvc.format.impl;

import java.util.Locale;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.servlet.support.RequestContext;
import com.abou.mvc.controller.ControllerUtils;

/**
 * The enumeration constants formatter
 * 
 * @author khalid
 */
public class EnumFormatter extends ATypeFormatterImpl<Enum<?>> {
  
  @Override
  protected String formatForType(Enum<?> value, Locale locale,
      HttpServletRequest request, RequestContext requestContext,
      boolean textOnly) {

    String msg =
        requestContext.getThemeMessage(ControllerUtils.ENUM_LABEL_CODE_PREFIX
            + value.getDeclaringClass().getSimpleName()
            + ControllerUtils.PATH_SEP
            + ControllerUtils.getMsgKey(value.name()));
    
    return msg;
  }
}
